package com.idealighter.game.web.checklevel.laba.controller.convert;

import com.idealighter.game.web.checklevel.laba.controller.dto.LaBaCheckResultDto;
import com.idealighter.game.web.checklevel.laba.service.bo.LaBaCheckResultBo;
import com.idealighter.game.web.checklevel.shuihu.service.ShuiHuBasicControlCheck.IdCount;
import com.idealighter.utils.check.EmptyUtil;

import java.util.ArrayList;
import java.util.List;

import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public abstract class LaBaCheckResultDtoConvert {
  public static final LaBaCheckResultDtoConvert INSTANCE =
      Mappers.getMapper(LaBaCheckResultDtoConvert.class);

  /**
   * bo转dto.
   * 
   * @Title bo2dto.
   * @date 2018年1月12日 下午5:48:27
   * @param bo bo对象
   * @return Dto
   */
  public LaBaCheckResultDto bo2dto(LaBaCheckResultBo bo) {
    LaBaCheckResultDto result = null;
    if (bo != null) {
      result = new LaBaCheckResultDto();
      result.setId(bo.getId());
      result.setBetChips(bo.getBetChips());
      result.setWinChips(bo.getWinChips());
      result.setBonus(bo.getBonus());
      result.setSgl(bo.getSgl());
      result.setBetCount(bo.getBetCount());
      result.setWinCount(bo.getWinCount());

      List<IdCount> list = new ArrayList<IdCount>();
      for (int id : bo.getTypeMap().keySet()) {
        Long count = bo.getTypeMap().get(id);
        IdCount item = new IdCount();
        item.setId(id);
        item.setCount(count);
        list.add(item);
      }
      result.setTypeList(list);
    }
    return result;
  }

  /**
   * bo列表转dto.
   * 
   * @Title bo2dto.
   * @author houdongsheng
   * @date 2018年1月12日 下午5:48:54
   * @param list bo列表
   * @return dto列表
   */
  public List<LaBaCheckResultDto> bo2dto(List<LaBaCheckResultBo> list) {
    List<LaBaCheckResultDto> resultList = null;
    if (EmptyUtil.listIsNotEmpty(list)) {
      resultList = new ArrayList<LaBaCheckResultDto>();
      for (LaBaCheckResultBo item : list) {
        LaBaCheckResultDto resultItem = new LaBaCheckResultDto();
        resultItem = bo2dto(item);
        resultList.add(resultItem);
      }
    }
    return resultList;
  }
}
